<?php
include '../newlib.php';
include '../lib/AppScope.pre.php';

$program = $_REQUEST["program"];
$position = intval($_REQUEST["position"]);

$stm = $tmpConnection->prepare('select * from programs where id=:id');
$stm->execute(array(':id' => $program));
$rs = $stm->fetch(PDO::FETCH_ASSOC);
$volgorde = $rs['volgorde'];
$exVolgorde = explode(";", $volgorde);
$resultingVolgorde = array_diff($exVolgorde, array("remove" => $position));
$volgorde = implode(";", $resultingVolgorde);
$stm = $tmpConnection->prepare('update programs set volgorde=:volgorde where id=:id');
$stm->execute(array(':volgorde' => $volgorde, ':id' => $program));

header("Location: editprog.php" . "?program=" . $program);
?>